home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_fists_m.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  210 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # WEAP_FISTS.COG
  4. #
  5. # WEAPON 1 Script - Fists
  6. #
  7. # The primary fire for is a punch with the left fist and then the right fist.
  8. #
  9. # - Not affected by MagSealed sectors/surfaces.
  10. #
  11. # [YB & CYW]
  12. #
  13. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  14.  
  15.  
  16. symbols
  17.  
  18. model       povModel=fistv.3do            local
  19. model       povModel_m=fistv_m.3do        local
  20. model       weaponMesh=fistg.3do          local
  21.  
  22. keyframe    mountAnim=FistVmnt.key            local
  23. keyframe    dismountAnim=FistVdis.key        local
  24. keyframe    povfireAnim1=FistVl.key            local
  25. keyframe    povfireAnim2=FistVr.key            local
  26. keyframe    holsterAnim=kyhlstr.key          local
  27.  
  28. sound       fireSound1=SwingFist01.wav        local
  29. #sound       fireSound2=SwingFist04.wav        local
  30.  
  31. template    projectile=+punch                    local
  32. template    projectileB=+bigpunch            local
  33.  
  34. thing       player                                local
  35.  
  36. flex        leftWait=0.25                        local
  37. flex        rightWait=0.25                        local
  38. flex        mountWait                            local
  39. flex        holsterWait                            local
  40.  
  41. int         trackID=-1                            local
  42. int         nextAnim=0                            local
  43. int            holsterTrack                        local
  44.  
  45. message     startup
  46. message     activated
  47. message     deactivated
  48. message     selected
  49. message     deselected
  50. #message     newplayer
  51. message     autoselect
  52. message     fire
  53. message        timer
  54.  
  55. end
  56.  
  57. # ========================================================================================
  58.  
  59. code
  60.  
  61. startup:
  62.    player = jkGetLocalPlayer();
  63.  
  64.    // Setup delays.
  65.    leftWait     = GetKeyLen(povfireAnim1) / 2;
  66.    rightWait    = GetKeyLen(povfireAnim2);
  67.    mountWait    = GetKeyLen(mountAnim);
  68.  
  69.    Return;
  70.  
  71. # ........................................................................................
  72.  
  73. fire:
  74.    // Check that the player is still alive.
  75.    if(GetThingHealth(player) <= 0)
  76.    {
  77.       Return;
  78.    }
  79.  
  80.     nextAnim = GetSenderRef();
  81.  
  82.     if (nextAnim < 0 || nextAnim > 1)
  83.         return;
  84.  
  85.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3.0, 0, 0, 0);
  86.    if(nextAnim == 0)
  87.    {
  88.             // Left jab (Poke!)
  89.       SetPOVShake('-0.01 -.01 0.0', '1.0 0.0 0.0', .05, 80.0);
  90.       PlaySoundThing(fireSound1, player, 1.0, 0.5, 2.5, 0x80);
  91.       FireProjectile(player, projectile, -1, 8, '-0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
  92.       SetFireWait(player, leftWait);
  93.  
  94. //        printflex(leftWait);
  95.    }
  96.    else
  97.    {
  98.             // Right hook (Thwack!)
  99.       SetPOVShake('0.01 -.01 0.0', '1.0 0.0 0.0', .05, 80.0);
  100.       PlaySoundThing(fireSound1, player, 1.0, 0.5, 2.5, 0x80);
  101.       FireProjectile(player, projectileB, -1, 18, '0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
  102.       SetFireWait(player, rightWait);
  103.  
  104. //        printflex(rightWait);
  105.    }
  106.  
  107.    jkPlayPOVKey(player, povfireAnim1[nextAnim], 1, 0x0a);
  108.  
  109.    Return;
  110.  
  111. # ........................................................................................
  112.  
  113. activated:
  114.    player = GetSourceRef();
  115.    mode = GetSenderRef();
  116.  
  117.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  118.    ActivateWeapon( player, leftWait, mode );
  119.  
  120.    Return;
  121.  
  122. # ........................................................................................
  123.  
  124. deactivated:
  125.    player = GetSourceRef();
  126.    mode = GetSenderRef();
  127.  
  128.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  129.    DeactivateWeapon( player, mode );
  130.  
  131.    Return;
  132.  
  133. # ........................................................................................
  134.  
  135. selected:
  136.    player = GetSourceRef();
  137.  
  138.    PlayMode(player, 40);
  139.  
  140.    // Setup the meshes and models.
  141.     if (GetInv(player, 67) == 0.0)
  142.         jkSetPOVModel(player, povModel);        // Kyle hand
  143.     else
  144.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  145.    jkSetWeaponMesh(player, weaponMesh);
  146.    SetArmedMode(player, 0);
  147.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  148.  
  149.    // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
  150.    // The animation is held at the last frame after it is played.
  151.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  152.    SetMountWait(player, mountWait);
  153.  
  154.    // Clear saber flags, and allow activation of the weapon
  155.    jkClearFlags(player, 0x5);
  156.    SetCurWeapon(player, 1);
  157.  
  158.    Return;
  159.  
  160. # ........................................................................................
  161.  
  162. deselected:
  163.    player = GetSourceRef();
  164.  
  165.    // Stop the mount's last frame animation, and play the dismount.
  166.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  167.     
  168.     holsterWait = GetKeyLen(holsterAnim);
  169.    SetMountWait(player, holsterWait);
  170.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  171.     SetTimerEx(holsterWait, 2, 0.0, 0.0);
  172.     if (trackID != -1)
  173.     {
  174.         jkStopPOVKey(player, trackID, 0);
  175.         trackID = -1;
  176.     }
  177.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  178.  
  179.    Return;
  180.  
  181. # ........................................................................................
  182.  
  183. //newplayer:
  184. //   player = GetSourceRef();
  185. //
  186. //   // Make sure that if the player is respawning, the old mount isn't playing anymore.
  187. //   if (trackID != -1)
  188. //   {
  189. //      jkStopPOVKey(player, trackID, 0);
  190. //      trackID = -1;
  191. //   }
  192. //
  193. //   Return;
  194.  
  195. # ........................................................................................
  196.  
  197. autoselect:
  198.    // Select fists when out of everything else...
  199.    ReturnEx(100.0);
  200.  
  201.    Return;
  202.  
  203. # ........................................................................................
  204.  
  205. timer:
  206.     StopKey(player, holsterTrack, 0.0);
  207.     Return;
  208.  
  209. end
  210.